package com.yuanduo_app.ui.map.adapter;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xujl.fastlib.base.BaseRvAdapter;
import com.xujl.fastlib.utils.ResUtils;

import com.yuanduo_app.R;
import com.yuanduo_app.entity.NearbyEntity;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import androidx.annotation.Nullable;

public class NearbyAdapter extends BaseRvAdapter<NearbyEntity> {
    private String keyword;

    public NearbyAdapter (@Nullable List<NearbyEntity> data) {
        super(R.layout.item_nearby_address, data);
    }

    @Override
    protected void convert (@NotNull BaseViewHolder holder, NearbyEntity entity) {
        holder.setText(R.id.tv_city,
                entity.getLocation().getName())
                .setText(R.id.tv_desc, entity.getLocation().getStreet())
                .setVisible(R.id.iv_checked, entity.isChecked());
        if (entity.isChecked()) {
            holder.setTextColor(R.id.tv_city, ResUtils.getColor(R.color.text_theme))
                    .setTextColor(R.id.tv_desc, ResUtils.getColor(R.color.text_theme))
                    .setBackgroundColor(R.id.ll, ResUtils.getColor(R.color.nearby_list_bg_p));
        } else {
            holder.setTextColor(R.id.tv_city, ResUtils.getColor(R.color.text_title))
                    .setTextColor(R.id.tv_desc, ResUtils.getColor(R.color.text_hint))
                    .setBackgroundColor(R.id.ll, ResUtils.getColor(R.color.white));
        }
    }

    public void setKeyword (String keyword) {
        this.keyword = keyword;
    }

    public String getKeyword () {
        return keyword;
    }
}
